// 使用懒加载进行组件的加载
import React, { Component, Suspense, lazy } from 'react';


// 引入路由
import { Switch, Route } from 'react-router-dom'

// 引入组件
const Detail = lazy(() => import('@/views/Detail'))
const Home = lazy(() => import('@/views/Home'))
const Login = lazy(() => import('@/views/Login'))
const Search = lazy(() => import('@/views/Search'))

class Routes extends Component {
    render() {
        return (
            // 路由规则
            <Suspense fallback={<div>加载中......</div>}>
                <Switch>
                    <Route path='/detail/:id' component={Detail}/>
                    <Route path='/Login' component={Login}/>
                    <Route path='/Search' component={Search}/>
                    <Route path='/' component={Home}/>
                </Switch>
            </Suspense>
        );
    }
}

export default Routes;
